<!DOCTYPE html>
<html lang="en">
<head>
	<include data="head.html">
	<title>分类目录</title>
</head>
<body data-menu="categories">
	<div class="container">
		<aside id="category-list">
			<h4>目录列表</h4>
			{!admin_list_categories(category_tree())}
		</aside>
		<section id="category-details">
			{!get_category($_GET)}
			<if data="!empty($_GET['action'])">
				<div class="page-header">
					<h4>{get_category() ? '更改' : '新建'}<i class="glyphicon glyphicon-remove"></i></h4>
				</div>
				<form role="form" action="{site_url()}mod.php?category::{get_category() ? 'update' : 'add'}" method="post" id="category-edit-form">
					<button type="submit" style="display: none">提交</button>
					<if data="get_category()">
						<input type="hidden" id="category_id" name="category_id" value="{category_id()}">
					</if>
					<div class="form-group">
						<label for="category_name">名称</label>
						<input type="text" class="form-control" id="category_name" name="category_name" value="{category_name()}" placeholder="在 URL 中作为路径使用" required>
					</div>
					<div class="form-group">
						<label for="category_alias">别名</label>
						<input type="text" class="form-control" id="category_alias" name="category_alias" value="{category_alias()}" placeholder="主显示名称">
					</div>
					<div class="form-group">
						<label for="category_desc">描述</label>
						<textarea class="form-control" id="category_desc" name="category_desc" placeholder="简单介绍这个目录的用途" rows="2">{category_desc()}</textarea>
					</div>
					<div class="form-group">
						<label for="category_parent">父目录</label>
						<select class="form-control" id="category_parent" name="category_parent">
							<option value="0">无</option>
							<foreach data="$categories as $k => $v">
								<option value="{$k}"{$k == category_parent('id') ? ' selected' : ''}>{$v}</option>
							</foreach>
						</select>
					</div>
				</form>
				<else>
					<div class="page-header">
						<h4>详情<i class="glyphicon glyphicon-remove"></i></h4>
					</div>
					<div class="page-contents">
						<div>
							<h5>名称</h5>
							<p id="category_name">{category_name()}</p>
						</div>
						<div>
							<h5>别名</h5>
							<p id="category_alias">{category_alias()}</p>
						</div>
						<div>
							<h5>描述</h5>
							<p id="category_desc">{category_desc()}</p>
						</div>
						<div>
							<h5>文章</h5>
							<p id="content-posts"></p>
						</div>
					</div>
				</else>
			</if>
		</section>
	</div>
	<include data="foot.html">
</body>
</html>